---
title: Load a code table
summary: Retrieve one or all rows of a task code table (action, category, priority, source) for translation and display.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
operation_id: OP-9
trigger: Application requests action/category/priority/source codes
---

# Load a code table

This operation loads one or all rows of a read-only task code table (`clsTaskActionCode`, `clsTaskCategoryCode`, `clsTaskPriorityCode`, `clsTaskSourceCode`, or their collections) for code↔description/enum translation.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-9 |
| **Trigger** | Application requests action/category/priority/source codes |
| **Inputs** | Optional `Code` and/or `TaskSourceCode` filter |
| **Outputs** | Populated code object or collection |
| **Primary components** | `clsTask*Code[Collection].GetCode(s)` |
| **Entry point** | `SAIF.Business.Tasks/clsTaskActionCode.vb`, `clsTaskActionCodeCollection.vb`, `clsTaskCategoryCode.vb`, `clsTaskCategoryCodeCollection.vb`, `clsTaskPriorityCode.vb`, `clsTaskPriorityCodeCollection.vb`, `clsTaskSourceCode.vb`, `clsTaskSourceCodeCollection.vb` |

## Steps

1. Build the nested `Criteria` with the DPI (plus `Code` and/or `TaskSourceCode` when applicable).
2. Call `DataAccessLayer.RetrieveObject(criteria)`.
3. `BeforeRetrieve` assigns `RetrieveSQL` and binds `:Code` / `:TaskSourceCode` where applicable ([SQL-003](../sql/SQL-003-select-task-action-code.md), [SQL-004](../sql/SQL-004-select-task-action-code-list.md), [SQL-006](../sql/SQL-006-select-task-category-code.md), [SQL-007](../sql/SQL-007-select-task-category-code-list.md), [SQL-009](../sql/SQL-009-select-task-priority-code.md), [SQL-010](../sql/SQL-010-select-task-priority-code-list.md), [SQL-011](../sql/SQL-011-select-task-source-code.md), [SQL-012](../sql/SQL-012-select-task-source-code-list.md)).
4. `AfterRetrieve` reads rows and, for collections, constructs and adds each code object via `Load`, which fills fields, builds a per-row `Criteria`, and calls `MarkOld()`.
5. `clsTaskCategoryCodeCollection` additionally sets `m_DataFound = True` per row, which drives its `IsValid` override ([BR-024](../business-rules.md#br-024-a-category-code-collection-is-valid-only-if-at-least-one-row-was-found)).
6. Any attempt to use the write-SQL properties (`CreateSQL`/`InsertSQL`/`UpdateSQL`/`DeleteSQL`) on any code-table criteria throws `ApplicationException(clsConstants.Messages.InvalidSQLProperty)` ([BR-023](../business-rules.md#br-023-code-tables-are-read-only-reference-data)).
   - Unrecognized priority or source codes map to a safe default (`Informational` / `NotAssigned`) rather than raising an error ([BR-025](../business-rules.md#br-025-unrecognized-codes-map-to-a-safe-default)).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([GetCode/GetCodes called]) --> S1["Build Criteria with DPI +<br>Code/TaskSourceCode"]
	S1 --> S2["RetrieveObject executes<br>RetrieveSQL"]
	S2 --> S3["AfterRetrieve reads rows via<br>Load"]
	S3 --> D{clsTaskCategoryCodeCollection?}
	D -->|Yes| S4[Set m_DataFound per row]
	D -->|No| EndOk(["Code object/collection<br>returned"])
	S4 --> EndOk
```

## Failure and edge-case behavior

- Code tables are strictly read-only; write-SQL access throws `ApplicationException` ([BR-023](../business-rules.md#br-023-code-tables-are-read-only-reference-data)).
- A category-code collection is valid only if at least one row was returned for the requested source system ([BR-024](../business-rules.md#br-024-a-category-code-collection-is-valid-only-if-at-least-one-row-was-found)).
- Unrecognized codes translate to safe enum defaults instead of throwing ([BR-025](../business-rules.md#br-025-unrecognized-codes-map-to-a-safe-default)).

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Business.Tasks/clsTaskActionCode.vb
- SAIF.Business.Tasks/clsTaskActionCodeCollection.vb
- SAIF.Business.Tasks/clsTaskCategoryCode.vb
- SAIF.Business.Tasks/clsTaskCategoryCodeCollection.vb
- SAIF.Business.Tasks/clsTaskPriorityCode.vb
- SAIF.Business.Tasks/clsTaskPriorityCodeCollection.vb
- SAIF.Business.Tasks/clsTaskSourceCode.vb
- SAIF.Business.Tasks/clsTaskSourceCodeCollection.vb
